package sharetime.playlist.service;

import java.util.List;

import org.springframework.stereotype.Service;

import sharetime.core.service.BaseManager;
import sharetime.playlist.domain.PlaylistResource;

@Service("playlistResourceManager")
public class DefaultPlaylistResourceManager extends BaseManager implements
		IPlaylistResourceManager {

	@Override
	public void createPlaylistResource(PlaylistResource pr) {
		dao.create(pr);
	}

	@Override
	public PlaylistResource getPlaylistResource(long id) {
		return dao.getInstanceById(PlaylistResource.class, id);
	}

	@Override
	public void removePlaylistResource(long id) {
		dao.remove(getPlaylistResource(id));
	}

	@Override
	public List<PlaylistResource> getPlaylistResourcesByPlaylistId(long id) {
		String[] params = { "playlistId" };
		Object[] values = { id };

		return dao.getInstancesByNamedQueryAndNamedParam(PlaylistResource.class,
				"getPlaylistResourcesByPlaylistId", params, values);
	}

}
